Network Architecture

  • Types of Multiplayer .

    • WebServer instead of a DedicatedServer, for simple things.

      • Example: pinball game with scoreboard.

    • Ghost Data instead of Concurrent Multiplayer.

      • Ghost Data refers to just a REPLAY of a different player, requiring only 1 network transfer at the start of the level, instead of being real-time.

      • Supposedly widely used in racing games and mobile games.

      • Example: penguin game.

    • Tips to make lag less frustrating:

      • Players can walk through other players.

        • In case of lag, there will be no collision problems.

      • It doesn’t matter who kills the enemy, everyone gets credit, no need to fight over loot.

      • "Basically single-player++".

  • Interview with Pat Wyatt .

    • Very good video.

    • Talks about random network things, with little focus on Netcode.

    • Overall, it's basically an interview with someone who works on networking and the challenges in each game.

    • Worth watching from start to finish.

    • Warcraft (1994):

      • Uses Lockstep, since the game is an RTS.

      • It's said that the code was not clean; it’s a mess.

    • Diablo (1997):

      • The game was made with a different network architecture in mind, so it was messy initially.

      • Determinism is required for lockstep.

      • The game was written in Haste.

      • P2P Lockstep, Client Authority was implemented.

      • {16:25}

        • "Does the client immediately see something happening, or wait for server confirmation?"

          • Answer: "You kill on your screen and inform the Level Master that the creature died, very loose. Easy to cheat."

          • Very insecure. Client-authority.

      • "Don't do a game like this. People will cheat".

    • Starcraft (1998):

      • Same as previous games.

    • Guild Wars (2005):

      • {19:42} File serving:

        • "Downloads the game while playing."

        • Everything is cached on the drive.

        • Each file has an ID and version.

        • "delta compress the difference between the file a person has and a file a person should have".

        • TCP.

      • {36:00}

        • Everything uses TCP throughout the game.

        • The host for the game is chosen.

        • Server separation:

          • "Component isolation split it into several servers."

          • "Even if the servers run on the same machine, it's better to have separate servers for organization and crash understanding."

          • Bottlenecks are discussed, so splitting into smaller servers allows horizontal scaling by adding more machines instead of upgrading the same one.

          • Also provides uptime protection: if one machine fails, others keep the connection active.

        • Protobuf is praised.

        • The game rarely needed downtime for updates.

        • Discusses TCP vs UDP extensively.

          • UDP is good for FirstPersonShooters.

          • TCP can be problematic with errors, mobile connections, etc.

        • "The server is authoritative for important things like position and which items players have, but clients..."

        • Tips:

          • "Always code assuming 1-minute RTT (ping) to consider failure cases."

  • <excalidraw_not_loaded>
  • Proto Hackers .

    • Exercises for server development.

Authority

  • It's a dilemma between synchronizing actions or synchronizing the consequences of actions.

Server-Authority
  • "The only 'authority' the client has is regarding its inputs, which are sent to the server, which 'notifies' the other clients."

  • "You want the client to have as little 'authority' as possible, so the server is the source of truth."

  • Inputs are done on the Client and passed to the Server, and ONLY the Server can move Entities and world objects.

  • The Client player is just an amoeba copying the Server's movements and properties, with no agency.

  • The Server has access to all "processes," while peers only have access to Inputs.

  • Synchronizing everything can be cumbersome and may cause unresponsiveness during lag.

  • Lag compensation is often necessary.

  • Safer against cheating.

  • Demonstration of this method ~{26:00 -> end} .

Client-Authority
  • The Client really PLAYS on the Client, while using RPCs to make other Clients' entities execute the same actions.

Peer-to-Peer (P2P)

  • Clients communicate directly with each other, without a central server making decisions.

  • Host-migration :

    • When the host disconnects, another host is chosen from the remaining peers.

    • Used in Halo, causing 'black screens' while waiting for the new host, and potential inconsistencies.

  • Hybrid 'P2P-Dedicated Server' in Destiny 1 .

    • Mainly discusses why P2P was chosen to ensure a 'responsive singleplayer experience' with better connectivity via ping-based matchmaking.

    • To compensate for P2P Host Migration issues, some crucial game states are saved on the Dedicated Server.

    • .

      • Hosts act as 'physics host,' simulating behavior, while critical mission progression is handled via the cloud.

      • Different 'host bubbles' can interact in the same activity, each with its own physics simulation, but mission progression remains the same.

    • Security issues of P2P are not discussed.

      • Exploit bugs are shown where raid bosses die in 1 hit because the host unplugged the LAN cable.

      • "We do allow a certain amount of exploit to happen in an individual console. We rely on other metrics to monitor and ban the player, retroactively."

    • "the host uses 44mb of data when they're running."

Dedicated Server

  • if OS.has_feature('dedicated_server'): .

  • if DisplayServer.get_name() == "headless": .

  • if "--server" in OS.get_cmdline_user_args(): .

  • game.exe --server --headless .

  • Exporting to a dedicated server .

  • The 'headless' version of the game should be lightweight, as it doesn’t need most scenes or visual elements, running in the terminal.

  • Server creation, with upload to Amazon EC2 .

    • "Amazon EC2 (Elastic Compute Cloud) is a cloud computing service by AWS, allowing users to rent virtual machines to run applications, websites, databases, and other services. With EC2, you can quickly launch and configure virtual servers, adjusting computing capacity to project needs, and pay only for the resources you use."

  • "Client on Windows, Server on Linux, much cheaper."

  • "Serverless":

    • Only works when someone is playing.

Bottlenecks